function sendStaffAjax(queryid,xml,id,innerId,type,selectID,inputID,subID){
	var qParamXML;
	if(xml!=null)
		qParamXML=xml;
	else{
		qParamXML="<root><params><param name='DATETYPE' value='3'></param><param name='rownum' value='10'></param></params></root>";
		$(inputID).val(10);
	}
	var params = {
		funcName:"query",
		queryId:queryid,
		qParamXML:qParamXML
	};

	$.ajax({
		url: localStorage.server_ip+''+CONFIG_PARAMS.app_path+'/clientAdaptor',
	  	dataType: 'xml',
	  	data:params,
		success:function(msg){
			if(type=="table")
				createStaffTable(msg,id,innerId);
			else
				createStaffZhu(msg,id,innerId);
		}
	});
	$(inputID).click(function(){
		$(this).val("");
	});
	$(inputID).blur(function(){
		if($(this).val()==""){
			$(this).val(10);
		}
	});
	$(subID).unbind().click(function(){
		$("#"+innerId).remove();
		var dtype=$(selectID).find("option:selected").val();
		var rownum=$(inputID).val();
		var qxml="<root><params><param name='DATETYPE' value='"+dtype+"'></param><param name='rownum' value='"+rownum+"'></param></params></root>";
		sendStaffAjax(queryid,qxml,id,innerId,type,selectID,inputID,subID)
	});
	
}

function createStaffTable(xml_data,id,innerId){
		$("#"+innerId).empty();
		var data = {};
		data.title = [];
		data.rows = [];
		$(xml_data).find("fieldmap").children().each(function(i){
			var label = $(this).get(0).attributes.getNamedItem("name").nodeValue;
			data.title.push(label);
		});
		$(xml_data).find("datas").children().each(function(i){
			var x=$(this).get(0).attributes.length;
			var list = [];
			for(var j=1;j<=x;j++){
			 	var label = $(this).get(0).attributes.getNamedItem('col'+j).nodeValue;
				list.push(label);
	  		}
	  		data.rows.push(list);
		});
		TABLETOOLS.createTable(data,id,"100%","200",[1,2],innerId);
}

function createStaffZhu(xml_data,id,innerId){
	var div = $("<div>").attr("id",innerId).addClass("graphCss");
	$(id).append(div).height($("#contentWarpper").height()-$(".top_menu").height());
	var x_name=[];var data1=[];var data2=[];
	var size=$(id).parent().parent().data("highChartNum");
		$(xml_data).find("row").each(function(i){
			if(i+1>size && size!=0)
				return false;
			var col1 = $(this).get(0).attributes.getNamedItem("col1").nodeValue;
			var col2 = parseInt($(this).get(0).attributes.getNamedItem("col2").nodeValue);
			var col3 = parseInt($(this).get(0).attributes.getNamedItem("col3").nodeValue);
			
			x_name.push(col1);
			data1.push(col2);
			data2.push(col3);
		});
		
        $("#"+innerId).highcharts({
            chart: {
                type: 'column',
                backgroundColor:CONFIG_PARAMS.GraphBackColor
            },
            title: {
                text: ''
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: x_name,
	            labels : { 
            		style:{
            			color:CONFIG_PARAMS.GraphFontColor
            		}
            	}
            },
            yAxis: {
                title: {
                    text: '销售业绩',
                    style:{
	            		color:CONFIG_PARAMS.GraphFontColor
	            	}
                },
                labels : { 
            		style:{
            			color:CONFIG_PARAMS.GraphFontColor
            		}
            	},stackLabels: {
                    enabled: true,
                    style: {
                        fontWeight: 'bold',
                        color: (Highcharts.theme && Highcharts.theme.textColor) || CONFIG_PARAMS.GraphFontColor
                    }
                }
            },
            legend:{
	        	itemStyle: {
                	color: CONFIG_PARAMS.GraphFontColor
            	},
            	labels : { 
            		style:{
            			color:CONFIG_PARAMS.GraphFontColor
            		}
            	}
	        },
	         tooltip: {
                shared: true
            },
            plotOptions: {
                column: {
                    dataLabels: {
                        enabled: true,
                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || CONFIG_PARAMS.GraphFontColor,
                		formatter:function(){
                			return this.y || "";
                		}
                    }
                }
            },
            series: [{
                name: "销售数量",
                data: data1
            }, {
                name: "销售金额",
                data: data2
            }]
        });
}